{extend name="tpl/site_0/default/pc/public/layout.html" /}
{block name="title"}{$webConfig.WEBNAME}{/block}
{block name="head"}
{/block}
{block name="body"}
{include file="tpl/site_0/default/pc/public/head.html" /}
商品名字:{$goodsInfo.fulltitle}<br>
商品价格:{$goodsInfo.simple_price}<br>
活动开始时间:{$goodsInfo.promotion_begin_time|date="Y-m-d H:i:s",###}<br>
活动开始时间:{$goodsInfo.promotion_end_time|date="Y-m-d H:i:s",###}<br>
数量:
<button type="button" onclick="$(this).next().val($(this).next().val()==$(this).next().attr('min')?$(this).next().val():parseInt($(this).next().val())-1)">-</button>
<input type="number" min="1" max="{$goodsInfo.goods_stock}" name="num" id="num" value="1">
<button type="button" onclick="$(this).prev().val($(this).prev().val()==$(this).prev().attr('max')?$(this).prev().val():parseInt($(this).prev().val())+1)">+</button><br>
<button type="button" onclick="join()">参加竞拍</button>
商品简介: <button type="button" onclick="$('#content').toggle()">显示/隐藏详情</button> <div id="content" style="display: none">{$goodsInfo.content}</div>
<hr>

{include file="tpl/site_0/default/pc/public/foot.html" /}
{/block}
{block name="script"}
<script src="/public/plugins/layer/layer.js"></script>
<script src="/public/plugins/template/template.js"></script>
<script type="text/html" id="join-tpl">
    <form id="form" action="">
        收货地址:
        <select name="address" id="">
            {{ each address as value}}
            <option value="{{ value.address_id}}">{{ value.address}}</option>
            {{ /each}}
        </select>
        <button type="button" onclick="sub()">提交</button>
    </form>
</script>
<script>
    function msg(address) {
        var num=$('#num').val();
        var data={address:address,info:{num:num}};
        var html=template('join-tpl',data);
        layer.open({
        type: 1,
        skin: 'layui-layer-rim', //加上边框
        area: ['420px', '240px'], //宽高
        content: html
    });

    }
    function join() {
        var index = layer.load();
        $.ajax({
            type:'ajax',
            url:'{:url("/home/User/addressList")}',
            success:function (data) {
                layer.close(index);
                if (data.code==0){
                    location.href=data.url
                }
                msg(data)
            }
        })
    }
    function sub() {
        var num=$('#num').val();
        var address=$('#address').val();
        $.post('{:url("promotionGroupBuyJoin")}',{promotion_type:4,num:num,sku_id:'{$goodsInfo.sku_id}',address_id:address},function (data) {
            layer.msg(data.msg);
            if (data.code){
                location.href=data.url
            }
        })
    }
</script>
{/block}